﻿using System;
using System.Drawing;
using Spencen.Mobile.UI.Transforms;

namespace Spencen.Mobile.UI.Transitions
{
    public class AnimateTransition : Transition
    {
        protected override void RenderFrame( Graphics compositeGraphics, Bitmap compositeBitmap, Bitmap newViewBitmap, Bitmap oldViewBitmap, Point startOffset, Brush backBrush, float adjustedValue )
        {
            var scale = 1.0f - adjustedValue;

            compositeGraphics.DrawImage( newViewBitmap, 0, 0 );
            compositeGraphics.DrawImage( oldViewBitmap,
                new Rectangle(
                    (int) ( oldViewBitmap.Width * ( 1 - scale ) / 2 ),
                    (int) ( oldViewBitmap.Height * ( 1 - scale ) / 2 ),
                    (int) ( oldViewBitmap.Width * scale ),
                    (int) ( oldViewBitmap.Height * scale ) ),
                new Rectangle( 0, 0, oldViewBitmap.Width, oldViewBitmap.Height ),
                GraphicsUnit.Pixel );
            //OldView.Transforms.Add( new ScaleTransform( scale, scale ) );
            //OldView.Render( new GraphicsContext( compositeGraphics, OldView ) );
        }
    }
}
